import {createStore} from 'redux'
import { isFloat32Array } from 'util/types'

// 初始数据

const defaultState:Istore = {
  num:10,
  token:"",
  homeTitle:"Java学科面试题",
  actionCode:"1334411120332562433",
  toastData:{
    isshow:false,    //是否展示
    message:"测试内容",//提示框的内容
    type:"error"   //提示框的颜色
  },
  
}

const reducer = (state = defaultState,action:Iaction)=>{
  let aa = JSON.parse(JSON.stringify(state))
  if(action.type === "toast_show"){
    let value = action.value as Itoast
    // 展示弹窗
    aa.toastData.isshow = true
    aa.toastData.message = value.message
    aa.toastData.type = value.type
  }else if(action.type === "toast_hide"){
    aa.toastData.isshow = false
  }else if(action.type === "token"){
    aa.token = action.value;
  }else if(action.type === "hometitle"){
    let value = action.value as Itoast2
    aa.homeTitle = value.a1;
    aa.actionCode = value.a2;
    console.log(state.homeTitle);
    console.log(state.homeTitle);
    
  }
  return aa
}

const store = createStore(reducer)
export default store
